<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ad_marketing_app_auth', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('媒体 marketing api 授权');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('media_id')->comment('媒体id')->unsigned()->default(0);
            $table->integer('media_user_id')->comment('媒体账号id')->unsigned()->default(0);
            $table->bigInteger('advertiser_id')->comment('媒体广告主id')->unsigned()->default(0);
            $table->integer('marketing_app_id')->comment('应用id')->unsigned()->default(0);
            $table->integer('update_time')->comment('更新时间')->unsigned()->default(0);
            $table->string('access_token', 64)->comment('令牌')->default('');
            $table->string('refresh_token', 50)->comment('刷新令牌')->default('');
            $table->string('access_token_expires_time', 50)->comment('令牌有效期')->default('');
            $table->string('refresh_token_expires_time', 50)->comment('刷新令牌有效期')->default('');
            $table->string('extends', 512)->comment('其他额外信息')->default('');

            $table->index('media_user_id');
            $table->index('advertiser_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ad_marketing_app_auth');
    }
};
